import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux'
import _ from 'lodash'

import { Table, Icon, Tag, Form,  Button, message, Modal, Input} from 'antd';
import { changePage, _maskRender } from '../../store/actions';
import SearchInput from '../../components/search-input'
const _data_= [
    {
        id:'',
        code:'1',
        diagnoseDate: '12-05 12:00-15:00',
        patientName:'张三',
        gender:'M',
        age:'23',
        decs:'症状描述症状描述症状描述症状描述症状描述症状描述',
        history:'颈椎病',
        modality:'CT',
        part:'胸部'
    },{
        id:'',
        code:'2',
        diagnoseDate: '12-05 12:00-15:00',
        patientName:'李四',
        gender:'F',
        age:'56',
        decs:'症状描述症状描述症状描述症状描述症状描述症状描述',
        history:'无',
        modality:'CR',
        part:'足部'
    }
];

class _pane1 extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            user: this.props.user,
            data: this.props.data
        };
    }
    render(){
        const rowSelection = {
            /*onChange(selectedRowKeys, selectedRows) {
             console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
             },
             onSelect(record, selected, selectedRows) {
             console.log(record, selected, selectedRows);
             },
             onSelectAll(selected, selectedRows, changeRows) {
             console.log(selected, selectedRows, changeRows);
             }*/
        };
        const columns = [{
            title: '序号',
            dataIndex: 'code',
        }, {
            title: '患者姓名',
            dataIndex: 'patientName',
        }, {
            title: '性别',
            dataIndex: 'gender',
            render(text){
                return text == 'M' ? '男' : (text == 'F' ? '女' : '未知')
            }
        }, {
            title: '年龄',
            dataIndex: 'age',
        }, {
            title: '症状描述',
            dataIndex: 'decs'
        }, {
            title: '过往病史',
            dataIndex: 'history'
        }, {
            title: '设备类型',
            dataIndex: 'modality'
        }, {
            title: '适用部位',
            dataIndex: 'part'
        }, {
            title: '接诊时间',
            dataIndex: 'diagnoseDate',
        } , {
            title: '操作',
            render(t,record){
                return (<div>
                    <a href="#" data-id={`${record.id}`}>查看影像</a>
                    <span className="ant-divider"> </span>
                    <a href="#" data-id={`${record.id}`}>详情</a>
                </div>)
            }
        }];
        const pagination = {
            total: this.state.data.length,
            showSizeChanger: true,
            onShowSizeChange(current, pageSize) {
                /*console.log('Current: ', current, '; PageSize: ', pageSize);*/
            },
            onChange(current) {
                /*console.log('Current: ', current);*/
            }
        };
        return (
          <div>
              <Table
                pagination={pagination}
                columns={columns}
                rowSelection={rowSelection}
                dataSource={this.state.data}
              />
          </div>
        )
    }
}
class _DiagnoseRecords extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            active:'1',
            defaultActiveKey:'1'
        };
        this.changeTag = this.changeTag.bind(this)
    }
    componentDidMount(){
        _maskRender();
    }
    componentWillMount(){
        //this.props.dispatch(changePage('template-manage'))
    }
    changeTag(e){
        this.setState({
            active:e
        })
    }
    render(){
        return (
          <div>
              <div style={{overflow: 'hidden', marginBottom: '10px', padding: '10px 0'}}>
                  <div style={{float:'left'}}>
                    <SearchInput style={{ width: 200 }} placeholder='请输入关键字查询' />
                  </div>
              </div>
              <_pane1 data={_data_} user={this.props.user} dispatch={this.props.dispatch} />
              <div id="_mask"></div>
          </div>
        )
    }
}
let DiagnoseRecords;
export default DiagnoseRecords = connect((state)=>{
    const {user} = state.rootReducer;
    return {user}
})(_DiagnoseRecords)

